package com.kunge2013.chatbi.vectordb;

import org.springframework.ai.document.Document;
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.VectorStore;

import java.util.List;
import java.util.Optional;

/**
 * @Author kunge2013
 * @Description 向量数据库接口
 * @Date 2024/11/10 12:46
 * @Version 1.0
 */
public interface VectorDbService extends VectorStore {
    /**
     * 新增
     *
     * @param documents the list of documents to store. Throws an exception if the
     * underlying provider checks for duplicate IDs.
     */
    void add(List<Document> documents);

    /**
     * 删除
     *
     * @param idList list of document ids for which documents will be removed.
     * @return
     */
    Optional<Boolean> delete(List<String> idList);

    /**
     * 查询
     *
     * @param request Search request for set search parameters, such as the query text,
     * topK, similarity threshold and metadata filter expressions.
     * @return
     */
    List<Document> similaritySearch(SearchRequest request);
}
